<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Spec::Rails::Matchers</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Spec::Rails::Matchers</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/__\__\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/assert_select_rb.html">
                ..\..\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/assert_select.rb
                </a>
        <br />
                <a href="../../../files/__\__\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/have_text_rb.html">
                ..\..\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/have_text.rb
                </a>
        <br />
                <a href="../../../files/__\__\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/redirect_to_rb.html">
                ..\..\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
                </a>
        <br />
                <a href="../../../files/__\__\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/render_template_rb.html">
                ..\..\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers/render_template.rb
                </a>
        <br />
                <a href="../../../files/__\__\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers_rb.html">
                ..\..\vendor\plugins\rspec_on_rails/lib/spec/rails/matchers.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Spec::Rails::Expectations::Matchers provides several expectation matchers
intended to work with <a href="../Rails.html">Rails</a> components like
models and responses. For example:
</p>
<pre>
  response.should redirect_to(&quot;some/url&quot;) #redirect_to(url) is the matcher.
</pre>
<p>
In addition to those you see below, the arbitrary predicate feature of
RSpec makes the following available as well:
</p>
<pre>
  response.should be_success #passes if response.success?
  response.should be_redirect #passes if response.redirect?
</pre>
<p>
Note that many of these matchers are part of a wrapper of
<tt>assert_select</tt>, so the documentation comes straight from that with
some slight modifications. <tt>assert_select</tt> is a Test::Unit extension
originally contributed to the <a href="../Rails.html">Rails</a> community
as a plugin by Assaf Arkin and eventually shipped as part of <a
href="../Rails.html">Rails</a>.
</p>
<p>
For more info on <tt>assert_select</tt>, see the relevant <a
href="../Rails.html">Rails</a> documentation.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000120">have_rjs</a>&nbsp;&nbsp;
      <a href="#M000117">have_tag</a>&nbsp;&nbsp;
      <a href="#M000123">have_text</a>&nbsp;&nbsp;
      <a href="#M000124">redirect_to</a>&nbsp;&nbsp;
      <a href="#M000125">render_template</a>&nbsp;&nbsp;
      <a href="#M000121">send_email</a>&nbsp;&nbsp;
      <a href="#M000122">with_encoded</a>&nbsp;&nbsp;
      <a href="#M000118">with_tag</a>&nbsp;&nbsp;
      <a href="#M000119">without_tag</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000120" class="method-detail">
        <a name="M000120"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000120.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000120.html');return false;">
          <span class="method-name">response.should have_rjs(*args, &block)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
wrapper for assert_select_rjs
</p>
<p>
see documentation for assert_select_rjs at <a
href="http://api.rubyonrails.org">api.rubyonrails.org</a>/
</p>
        </div>
      </div>

      <div id="method-M000117" class="method-detail">
        <a name="M000117"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000117.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000117.html');return false;">
          <span class="method-name">response.should have_tag(*args, &block)<br />
string.should have_tag(*args, &block)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
wrapper for assert_select with additional support for using css selectors
to set expectation on Strings. Use this in helper specs, for example, to
set expectations on the results of helper methods.
</p>
<h2>Examples</h2>
<pre>
  # in a controller spec
  response.should have_tag(&quot;div&quot;, &quot;some text&quot;)

  # in a helper spec (person_address_tag is a method in the helper)
  person_address_tag.should have_tag(&quot;input#person_address&quot;)
</pre>
<p>
see documentation for assert_select at <a
href="http://api.rubyonrails.org">api.rubyonrails.org</a>/
</p>
        </div>
      </div>

      <div id="method-M000123" class="method-detail">
        <a name="M000123"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000123.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000123.html');return false;">
          <span class="method-name">response.should have_text(expected)<br />
response.should_not have_text(expected)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Accepts a String or a Regexp, matching a String using == and a Regexp using
=~.
</p>
<p>
Use this instead of <tt>response.should <a
href="Matchers.html#M000117">have_tag</a>()</tt> when you either
don&#8216;t know or don&#8216;t care where on the page this text appears.
</p>
<h2>Examples</h2>
<pre>
  response.should have_text(&quot;This is the expected text&quot;)
</pre>
        </div>
      </div>

      <div id="method-M000124" class="method-detail">
        <a name="M000124"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000124.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000124.html');return false;">
          <span class="method-name">response.should redirect_to(url)<br />
response.should redirect_to(:action => action_name)<br />
response.should redirect_to(:controller => controller_name, :action => action_name)<br />
response.should_not redirect_to(url)<br />
response.should_not redirect_to(:action => action_name)<br />
response.should_not redirect_to(:controller => controller_name, :action => action_name)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if the response is a redirect to the url, action or
controller/action. Useful in controller specs (integration or isolation
mode).
</p>
<h2>Examples</h2>
<pre>
  response.should redirect_to(&quot;path/to/action&quot;)
  response.should redirect_to(&quot;http://test.host/path/to/action&quot;)
  response.should redirect_to(:action =&gt; 'list')
</pre>
        </div>
      </div>

      <div id="method-M000125" class="method-detail">
        <a name="M000125"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000125.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000125.html');return false;">
          <span class="method-name">response.should render_template(path)<br />
response.should_not render_template(path)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Passes if the specified template is rendered by the response. Useful in
controller specs (integration or isolation mode).
</p>
<p>
<tt>path</tt> can include the controller path or not. It can also include
an optional extension (no extension assumes .rhtml).
</p>
<p>
Note that partials must be spelled with the preceding underscore.
</p>
<h2>Examples</h2>
<pre>
  response.should render_template('list')
  response.should render_template('same_controller/list')
  response.should render_template('other_controller/list')

  #rjs
  response.should render_template('list.rjs')
  response.should render_template('same_controller/list.rjs')
  response.should render_template('other_controller/list.rjs')

  #partials
  response.should render_template('_a_partial')
  response.should render_template('same_controller/_a_partial')
  response.should render_template('other_controller/_a_partial')
</pre>
        </div>
      </div>

      <div id="method-M000121" class="method-detail">
        <a name="M000121"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000121.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000121.html');return false;">
          <span class="method-name">response.should send_email(*args, &block)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
wrapper for assert_select_email
</p>
<p>
see documentation for assert_select_email at <a
href="http://api.rubyonrails.org">api.rubyonrails.org</a>/
</p>
        </div>
      </div>

      <div id="method-M000122" class="method-detail">
        <a name="M000122"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000122.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000122.html');return false;">
          <span class="method-name">with_encoded</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
wrapper for assert_select_encoded
</p>
<p>
see documentation for assert_select_encoded at <a
href="http://api.rubyonrails.org">api.rubyonrails.org</a>/
</p>
        </div>
      </div>

      <div id="method-M000118" class="method-detail">
        <a name="M000118"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000118.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000118.html');return false;">
          <span class="method-name">with_tag</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
wrapper for a nested assert_select
</p>
<pre>
  response.should have_tag(&quot;div#form&quot;) do
    with_tag(&quot;input#person_name[name=?]&quot;, &quot;person[name]&quot;)
  end
</pre>
<p>
see documentation for assert_select at <a
href="http://api.rubyonrails.org">api.rubyonrails.org</a>/
</p>
        </div>
      </div>

      <div id="method-M000119" class="method-detail">
        <a name="M000119"></a>

        <div class="method-heading">
          <a href="Matchers.src/M000119.html" target="Code" class="method-signature"
            onclick="popupCode('Matchers.src/M000119.html');return false;">
          <span class="method-name">without_tag</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
wrapper for a nested assert_select with false
</p>
<pre>
  response.should have_tag(&quot;div#1&quot;) do
    without_tag(&quot;span&quot;, &quot;some text that shouldn't be there&quot;)
  end
</pre>
<p>
see documentation for assert_select at <a
href="http://api.rubyonrails.org">api.rubyonrails.org</a>/
</p>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>